//
//  HRCoverImageModel.m
//  Hear
//
//  Created by mac on 2017/4/19.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRCoverImageModel.h"
@implementation HRCoverImageModel
+(void)OriginImage:(UIImage *)image scaleToSize:(CGSize)size callBackOriginImage:(void(^)(UIImage *originImage))callBackOriginImageBlock
{
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);

        
        [image drawInRect:CGRectMake((size.width-size.width*0.7)/2, (size.height-size.height*0.9)/2, size.width*0.7, size.height*0.9)];
        
        
        UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();
        

        dispatch_async(dispatch_get_main_queue(), ^{
           callBackOriginImageBlock(scaledImage);
        });

    });
    
    
    
}
@end
